//
//  BinningBracketCell.m
//  CJRailTransport
//
//  Created by Hank on 2017/12/28.
//  Copyright © 2017年 amplity. All rights reserved.
//

#import "BinningBracketCell.h"

@implementation BinningBracketCell

// 设置数据
- (void)setData:(NSString *)contentStr GPSStr:(NSString *)GPSStr
{
    self.numberLabel.text = [NSString stringWithFormat:@"%ld",self.indexPath.row + 1];
    // 设置恢复的内容
    if (JudgeStrNotEqualNull(contentStr)) {
        self.contentLabel.text = contentStr;
    }
    if (JudgeStrNotEqualNull(GPSStr)) {
        self.GPSLabel.text = GPSStr;
    }
    // 扫码添加手势
    [self addTapGestureRecognizer:self.scanImage action:@selector(scanBtnAction)];
    [self addTapGestureRecognizer:self.GPSImage action:@selector(GPSBtnAction)];
}
// 扫码添加手势
- (void)addTapGestureRecognizer:(UIImageView *)imageView action:(SEL)action
{
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:action];
    //设置点击次数和点击手指数
    tapGesture.numberOfTapsRequired = 1; //点击次数
    tapGesture.numberOfTouchesRequired = 1; //点击手指数
    [imageView addGestureRecognizer:tapGesture];
}

// 去除分割线
- (UIView *)lineView
{
    return [[UIView alloc]init];
}

#pragma mark - Action
// 扫码 Action
- (void)scanBtnAction
{
    // 扫码托盘/支架更新数据 Block
    _updateDataBlock(self.indexPath, @"1");
}
// GPS 扫码 Action
- (void)GPSBtnAction
{
    // 扫码GPS更新数据 Block
    _updateDataBlock(self.indexPath, @"2");
}

// 修改支架/托盘编码 Action
- (IBAction)changeCodeAction:(UIButton *)sender
{
    // 修改支架/托盘编码 Block
    _changeCodeBlock(self.indexPath, [NSString stringWithFormat:@"%ld",sender.tag]);
}

// 防止手势冲突
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
    
    if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {
        return NO;
    }
    return YES;
    
}

@end
